package com.example.cool_core.http;

import com.example.cool_core.config.PublicConfig;

public abstract class CoolHttpObserver<T> extends BaseHttpObserver<T> {
    protected PublicConfig mPublicConfig;

    public CoolHttpObserver(PublicConfig mPublicConfig) {
        this.mPublicConfig = mPublicConfig;
    }

    public CoolHttpObserver(Object tag, PublicConfig mPublicConfig) {
        super(tag);
        this.mPublicConfig = mPublicConfig;
    }

    public CoolHttpObserver(Object tag) {
        super(tag);
    }

    public CoolHttpObserver() {
    }

    @Override
    protected void HttpStart() {
        showLoading();
    }


    @Override
    protected void HttpError(Throwable e) {
        showError();
    }

    @Override
    protected void HttpSuccess(T t) {
        showContent();
    }

    protected void showLoading() {
        if (mPublicConfig != null) {
            mPublicConfig.showLoading();
        }
    }

    protected void showContent() {
        if (mPublicConfig != null) {
            mPublicConfig.showContent();
        }
    }

    protected void showError() {
        if (mPublicConfig != null) {
            mPublicConfig.showError();
        }
    }
}
